package com.lihaozhe.controller;

import com.fasterxml.jackson.annotation.JsonView;
import com.lihaozhe.constant.CommonConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 李昊哲
 * @version 1.0
 * 2021/11/28 12:38
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {
    private final CommonConstant commonConstant;

    public TestController(CommonConstant commonConstant) {
        this.commonConstant = commonConstant;
    }

    @GetMapping("/commonConstant")
    @JsonView(CommonConstant.class)
    public CommonConstant getCommonConstant() {
        log.info("getCommonConstant");
        log.info("title = {}", commonConstant.getTitle());
        log.info("slogan = {}", commonConstant.getSlogan());
        return commonConstant;
    }

    @PostMapping("/commonConstant")
    @JsonView(CommonConstant.class)
    public CommonConstant postCommonConstant() {
        log.info("postCommonConstant");
        log.info("title = {}", commonConstant.getTitle());
        log.info("slogan = {}", commonConstant.getSlogan());
        return commonConstant;
    }
}